package com.bujunjie.study.realtime.common.function;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.alibaba.fastjson.serializer.SerializeConfig;
import org.apache.flink.api.common.functions.MapFunction;

/**
 * <p>对象转map function 的方法</p>
 *
 * @author bu.junjie
 * @version 1.0.0
 * @createTime 2025/9/18 15:19
 */
public class Object2JsonStringFunction<T> implements MapFunction<T, String> {
    @Override
    public String map(T value) throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setPropertyNamingStrategy(PropertyNamingStrategy.SnakeCase);
        return JSON.toJSONString(value, config);
    }
}
